package jp.sourceforge.akjrcp.ui.param;

import jp.sourceforge.akjrcp.ui.param.AbstractParamCompositeItem.ModifiCheck;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class ParamTextArea extends AbstractParamCompositeItem{

private String key;
private String label;

private Text text;
private Label labelItem;

private String value="";

public Text getTextComposite(){
	return text;
}
public String getKey() {
	return key;
}

public String getLabel() {
	return label;
}



public void setToolTipText(String text){
	labelItem.setToolTipText(text);
	this.text.setToolTipText(text);
}



public String getValue() {
	return text.getText();
}


public void setValue(String value) {
	text.setText(value);
	this.value=value;
}

	public ParamTextArea(Composite parent, int style,String key,String label) {
		this(parent,style,key,label,30);
	}
	
	public ParamTextArea(Composite parent, int style,String key,String label,int width) {
		super(parent, style);
		
		this.key=key;
		this.label=label;
		
		this.setLayout(new GridLayout(1,false));
		labelItem = new Label(this,SWT.NONE);
		labelItem.setText(label);
		
		text = new Text(this,SWT.V_SCROLL|SWT.H_SCROLL);
		text.addModifyListener(new ModifiCheck());
		
		GridData gdata;
		if(width<0){
		gdata=new GridData();
			gdata=new GridData(GridData.FILL_BOTH);
		}else if(width==0){
			gdata=new GridData(GridData.FILL_HORIZONTAL);
		}else{
			gdata=new GridData();
			gdata.widthHint=width;
		}
		text.setLayoutData(gdata);
		
	}


	
	public boolean isModified() {
		
		String oldValue=text.getText();
		
		
		
		return !oldValue.equals(value);
	}



}
